using System.Collections;
using System.Collections.Generic;
using TEngine;
using UnityEngine;

namespace GameLogic
{
    public class AudioPlayCom : MonoBehaviour
    {
        [SerializeField]
        string m_AudioKey = "";
        [SerializeField]
        TEngine.AudioType m_AudioType = TEngine.AudioType.UISound;
        void Start()
        {
            Play(m_AudioKey);
        }

        // Update is called once per frame
        void Update()
        {
        
        }
        public void Play(string key)
        {
            if (key == "")
                key = m_AudioKey;

            var audioCfg = ConfigSystem.Instance.Tables.TbAudio.GetOrDefault(key);
            if (audioCfg != null)
                GameModule.Get<AudioModule>().Play(m_AudioType, audioCfg.Path);
        }
    }
}
